package com.cykj.controller;

import com.cykj.dto.ResponseDto;
import com.cykj.service.AppointmentTimeService;
import com.cykj.vo.AppointmentTimeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @BelongsProject: Psychology
 * @BelongsPackage: com.cykj.controller
 * @Author: 小林
 * @CreateTime: 2025-02-11 13:39
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/appointmentTime")
public class AppointmentTimeController {
    @Autowired
    private AppointmentTimeService appointmentTimeService;

    /**
     * 插入预约时间
     * @param vo 包含预约时间信息的对象
     * @return 插入操作的响应结果
     */
    @RequestMapping("insertAppointmentTime")
    public ResponseDto insert(@RequestBody AppointmentTimeVo vo) {
        try {
            return appointmentTimeService.insert(vo);
        } catch (Exception e) {
            return ResponseDto.error("设置失败");
        }
    }
    /**
     * 根据条件搜索预约时间
     * @param vo 包含搜索条件的对象
     * @return 搜索操作的响应结果
     */
    @RequestMapping("searchAppointmentTime")
    public ResponseDto search(@RequestBody AppointmentTimeVo vo) {
        return appointmentTimeService.search(vo);
    }

    /**
     * 搜索所有预约时间
     * @return 包含所有预约时间信息的响应结果
     */
    @RequestMapping("searchAllTime")
    public ResponseDto searchAllTime() {
        return appointmentTimeService.searchAll();
    }
}

